﻿using Pay.Data;
using Pay.DTO;
using Pay.IService;
using Pay.Service.Cache;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service {
   public class TokenGradeService : ServiceBase, ITokenGradeService, IDisposable {
        private IUnitOfWork _iUnitOfWork;
 
        public TokenGradeService(IUnitOfWork iUnitOfWork) : base(iUnitOfWork) {
            _iUnitOfWork = iUnitOfWork;
        }

        public token_grade_dto Get(long id) {
            var model = context.TokenGrade.FindById(id);
            if (model != null)
                return model.ToDtoObject<token_grade_dto>();
            else return null;
        }
        public token_grade_dto Get(UserType userType) {
            var model = context.TokenGrade.FirstOrDefault(s => s.UserType == userType && s.IsEnable);
            if (model != null)
                return model.ToDtoObject<token_grade_dto>();
            else return null;
        }
    }
}
